package 最值算法.最大的第三个数;

import java.util.*;
import java.util.stream.Collectors;

public class zddsgs {
    /**
     * 愚蠢的方法
     * @param args
     */
    public static void main(String[] args) {
         int[] nums = {5,2,4,1,3,6,0};
         System.out.println(thirdMax(nums));

    }

    public static int thirdMax(int[] nums) {


        int[] ints = Arrays.stream(nums).sorted().distinct().toArray();

        System.out.println(Arrays.toString(ints));

        return  ints.length > 2?ints[ints.length - 3]:ints[ints.length-1];

    }
}
